global keepers1988 ""


numlabel, add

drop if v5==2

drop if v2~=12

genl yr=1988
global keepers1988 $keepers1988 yr

genl id=v1
global keepers1988 $keepers1988 id

merge 1:1 v1 using "$sourcedatadir/se/vu88ink.dta" /* Note: duplicate observations deleted from the file first using */
/* duplicates drop */
drop if _merge==2

genl income=S6
genl income3=income
centile income, c(33 66 100)
replace income3=0 if income<=r(c_1)
centile income, c(33 66 100)
replace income3=1 if income>r(c_1) & income<=r(c_2)
centile income, c(33 66 100)
replace income3=2 if income>r(c_2) & income<=r(c_3)
global keepers1988 $keepers1988 income3

genl pid_ce=(v167==22 & v168==1)
replace pid_ce=. if v166==.
global keepers1988 $keepers1988 pid_ce

gen pid_gov=pid_ce
global keepers1988 $keepers1988 pid_gov

genl vote_ce=v182
recode vote_ce 22=1 .=. else=0
global keepers1988 $keepers1988 vote_ce

genl vote_gov=vote_ce
global keepers1988 $keepers1988 vote_gov



genl gpi=v25
recode gpi 8=2.5
replace gpi=abs(gpi-4)/3
global keepers1988 $keepers1988 gpi

genl socref=v149
recode socref 8=2.5
replace socref=abs(socref-4)/3
global keepers1988 $keepers1988 socref

genl degree=v299
recode degree 7=1 1/6 8=0
global keepers1988 $keepers1988 degree


// Class/occupation

gen class_reho_3cat_strata = v391
recode class_reho_3cat_strata 1=1 2=1 3=2 4=2 5=1 6=2 7=2 8=. 10=. 88=. 96=. 99=.
replace class_reho_3cat_strata = . if class_reho_3cat_strata > 40
label variable class_reho_3cat_strata "Social class (3 cats.): higher value is higher class"
*label define LblClassGrade 1 "A: (Higher man.; prof." 2 "B: Lower man.; admin." 3 "C1A: Skilled; supervis. non-manu." 4 "C1B: Lower non-manu." 5 "C2: Skilled manu." 6 "D: Unskilled manu."
*label values class_head_grade LblClassGrade
global keepers1988 $keepers1988 class_reho_3cat_strata

gen male = v366
recode male 1=1 2=0
global keepers1988 $keepers1988 male

gen married = v330
recode married 1=1 2/3=0 6=. 9=.
global keepers1988 $keepers1988 married

gen unionmem_resp = v323
recode unionmem_resp 1/4=1 5=0 6=. 8=. 9=.
global keepers1988 $keepers1988 unionmem_resp

*gen unionmem_spou = v259
*recode unionmem_spou 1/4=1 .=0
*global keepers1979 $keepers1979 unionmem_spou



// Pascal/SM moderators


gen party_ID=. 
   replace party_ID=1 if v166==1 & v167==11
   replace party_ID=2 if v166==1 & v167==22
   replace party_ID=3 if v166==1 & v167==33
   replace party_ID=4 if v166==1 & v167==44
  
   replace party_ID=6 if v166==1 & v167==66
   replace party_ID=7 if v166==1 & v167==87

   replace party_ID=8 if v166==1 & v167==88
   
   replace party_ID=9 if v166==1 & v167==12
 
   replace party_ID=10 if v166==1 & v167==55
 
 replace party_ID=11 if v166==1 & v167==13
 replace party_ID=12 if v166==1 & v167==71
 replace party_ID=13 if v166==1 & v167==72
 replace party_ID=14 if v166==1 & v167==73
replace party_ID=15 if v166==1 & v167==82
replace party_ID=16 if v166==1 & v167==14
replace party_ID=17 if v166==1 & v167==15
replace party_ID=18 if v166==1 & v167==9

 lab def party_ID 1 "v‰nsterpartiet kom " 2 "socialdemokraterna" 3"centerpartiet" 4"folkpartiet" 5"hˆgerpartiet" 6"kristen demokratis" 7 "other" 8 "will not answer"9 " kommunistiska fˆrbundet marxist-len" 10 " moderata samlingspartiet " 11 "sveriges kommunis" 12 "borgerligt "  13 "FC+C" 14 "lokal borgerlig" 15 "skÂnepartiet" 16 "kommunistiska arbetarefˆrbundet" 17 "vpk, apk, kpmlr, skp, kaf" 18 "grˆnt parti" 19 "ny demokrati"
 lab val party_ID party_ID
  tab party_ID, m
 tab party_ID v167, m
 
 foreach var of varlist  v112 v113 v115 v116 v120 v121 v123{
        gen Z`var'=`var'
		replace Z`var'=5 if `var'==1
		replace Z`var'=4 if `var'==2
		replace Z`var'=3 if `var'==8 | `var'==3
		replace Z`var'=2 if `var'==4
		replace Z`var'=1 if `var'==5
		replace Z`var'=(Z`var'-1)/4
		tab Z`var' `var', m
  }


rename Zv112 cut_public
lab var cut_public "1=good idea to reduce size of public sector"

rename Zv113 abolish_transfer
lab var abolish_transfer"1=good idea abolish the wage earners' funds"

rename Zv115 cut_benefit
lab var cut_benefit "1=good idea to reduce social benefits"

rename Zv116 red_tax_high
lab var red_tax_high "1=good idea to cut taxes on high incomes" 

rename Zv120 privatize 
lab var privatize "1=good idea to sell public companies" 

rename Zv121 reduce_inequalities
lab var reduce_inequalities "1=good idea to reduce income differences" 

rename Zv123 private_health
lab var private_health "1=good idea to increase private run health care"




gen newspaper_politics=.
 replace newspaper_politics=0 if v18==1
 replace newspaper_politics=0.33 if v18==2
 replace newspaper_politics=0.66 if v18==3
 replace newspaper_politics=1 if v18==4
  replace newspaper_politics=0.5 if v18==5
tab newspaper_politics v18,m
 lab var newspaper_politics "1=read more politic articles"



     gen talk_politic=.
 replace talk_politic=1 if v26==1
 replace talk_politic=0.66 if v26==2
replace talk_politic=0.33 if v26==3
replace talk_politic=0 if v26==4
replace talk_politic=0.5 if v26==8
 replace talk_politic=. if v26==6 | v26==9
 
 tab v26 talk_politic, m
  lab var talk_politic "1=often talk politic outside and inside family" 


gen right=v178/10
replace right=0.50 if right>1 & right~=.
  tab right v178, m
  lab var right "1=far right"


foreach var of varlist  v156 v158 v157{
        gen Z`var'=`var'/10
		replace Z`var'=0.5 if Z`var'>1
		replace Z`var'=. if `var'==.
			tab Z`var' `var', m
  }

rename Zv156 m_market_oriented
lab var m_market_oriented"1=favor move toward more free-market"

rename Zv158 m_income_gap
lab var m_income_gap"1=favor move toward with wider income gaps "

rename Zv157 m_socialism
lab var  m_socialism "1=favor move toward socialism"


gen transfer2=.
replace transfer2=1 if v140==1
replace transfer2=0.5 if v140==3 | v140==8
replace transfer2=0 if v140==5
replace transfer2=. if v140==6 | v140==9
lab var transfer2 "1=favor transfer business profit to union funds"
tab transfer2 v140, m


 foreach var of varlist v148{
        gen Z`var'=`var'
		replace Z`var'=1 if `var'==4
		replace Z`var'=2 if `var'==3
		replace Z`var'=2.5 if `var'==8
		replace Z`var'=3 if `var'==2
		replace Z`var'=4 if `var'==1
            replace Z`var'=. if `var'==6 | `var'==9 
		replace Z`var'=(Z`var'-1)/3
		tab Z`var' `var', m
  }



    rename Zv148 econ_control
  lab var  econ_control "1=agree state control limit bank and industry influence"


gen anti_econ_control=.
replace anti_econ_control=0.3333333 if econ_control>0.5 & econ_control<1
replace anti_econ_control=0.6666666 if econ_control>0 & econ_control<0.5
replace anti_econ_control=1 if econ_control==0
replace anti_econ_control=0.5 if econ_control==0.5
replace anti_econ_control=0 if econ_control==1
tab anti_econ_control econ_control, m

gen anti_transfer2=.
replace anti_transfer2=1 if transfer2==0
replace anti_transfer2=0 if transfer2==1
replace anti_transfer2=0.5 if transfer2==.5
tab  anti_transfer2 transfer2, m

gen anti_m_socialism=.
replace anti_m_socialism=0 if m_socialism==1
replace anti_m_socialism=0.1 if m_socialism>=0.88 & m_socialism<=0.91 
replace anti_m_socialism=0.2 if m_socialism>=0.78 & m_socialism<=0.81 
replace anti_m_socialism=0.3 if m_socialism>=0.68 & m_socialism<=0.71 
replace anti_m_socialism=0.4 if m_socialism>=0.58 & m_socialism<=0.61 
replace anti_m_socialism=0.5 if m_socialism>=0.48 & m_socialism<=0.51 
replace anti_m_socialism=0.6 if m_socialism>=0.38 & m_socialism<=0.41 
replace anti_m_socialism=0.7 if m_socialism>=0.28 & m_socialism<=0.31 
replace anti_m_socialism=0.8 if m_socialism>=0.18 & m_socialism<=0.21 
replace anti_m_socialism=0.9 if m_socialism>=0.08 & m_socialism<=0.11 
replace anti_m_socialism=1 if m_socialism==0
tab anti_m_socialism m_socialism, m

gen index_interest=(gpi+ talk_politic+ newspaper_politics )/3
global keepers1988 $keepers1988 index_interest

gen index_market_oriented=(  cut_public +abolish_transfer+  privatize+ private_health +right+ m_market_oriented +anti_m_socialism +anti_transfer2 +anti_econ_control  )/9
global keepers1988 $keepers1988 index_market_oriented
